<%@ page import="java.util.List" %>
<%@ page import="com.blank.pojo.bo.Book" %><%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2020/11/19
  Time: 20:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>显示所有图书</title>
</head>
<body>
<table>
    <tr>
        <th>id</th>
        <th>BookName</th>
        <th>BookType</th>
        <th>Editor</th>
    </tr>
    <c:forEach var="book" items="${list}">
        <tr>
            <td>${book.id}</td>
            <td>${book.bookName}</td>
            <td>${book.bookType}</td>
            <td>${book.editor}</td>
        </tr>
    </c:forEach>
</table>
<div>
    <!-- 页数等于 总数/每页显示数+1 || 总数%每页显示数==0-->
   <%
       List<Book> list =(List<Book>)session.getAttribute("list");
       int count=(int) session.getAttribute("num");
       int num;
       if (count%3==0){
           num=count/3;
       }else {
           num=count/3+1;
       }
       String result="共计： ";
       for (int i=1;i<=num;i++){
           result+="<a href='BookSelectPage?page="+i+"'>"+i+"</a> &nbsp;";
       }
       out.write(result );
   %>
</div>
</body>
</html>
